package com.ykt.converter;

import com.ykt.common.thirdapi.ys7.model.Ys7Camera;
import com.ykt.common.utils.UB;
import com.ykt.model.Camera;

import java.util.ArrayList;
import java.util.List;

/**
 * 类型转换器
 * @author long.hua
 * @version 1.0.0
 * @since 2016-01-09 23:25
 */
public class CameraConverter {



    public static Ys7Camera convert(Camera model){
        if(model == null){
            return null;
        }

        Ys7Camera vo = new Ys7Camera();

        vo.setId(model.getId());
        vo.setCameraId(model.getStr(Camera.camera_id));
        vo.setCameraName(model.getStr(Camera.camera_name));
        vo.setCameraNo(model.getStr(Camera.camera_no));
        vo.setDeviceId(model.getStr(Camera.device_id));
        vo.setDeviceSerial(model.getStr(Camera.device_serial));
        vo.setDeviceName(model.getStr(Camera.device_name));
        vo.setPicUrl(model.getStr(Camera.pic_url));
        vo.setDefence(UB.i(model.getInt(Camera.defence), -1));
        vo.setIsEncrypt(UB.i(model.getInt(Camera.is_encrypt), -1));
        vo.setIsShared(UB.i(model.getInt(Camera.is_shared), -1));
        vo.setStatus(UB.i(model.getInt(Camera.status), -1));

        return vo;
    }

    public static List<Ys7Camera> convert(List<Camera> models){
        if(models == null || models.isEmpty()){
            return null;
        }

        List<Ys7Camera> list = new ArrayList<>();
        for (Camera model : models) {
            Ys7Camera vo = convert(model);
            if(vo != null){
                list.add(vo);
            }
        }

        return list;
    }

}
